package com.qingcheng.controller.order;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.entity.PageResult;
import com.qingcheng.entity.Result;
import com.qingcheng.pojo.order.OrderDeal;
import com.qingcheng.service.order.OrderDealService;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/orderDeal")
public class OrderDealController {

    @Reference
    private OrderDealService orderDealService;

    @GetMapping("/findAll")
    public List<OrderDeal> findAll(){
        return orderDealService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<OrderDeal> findPage(int page, int size){
        return orderDealService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<OrderDeal> findList(@RequestBody Map<String,Object> searchMap){
        return orderDealService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<OrderDeal> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  orderDealService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public OrderDeal findById(Integer id){
        return orderDealService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody OrderDeal orderDeal){
        orderDealService.add(orderDeal);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody OrderDeal orderDeal){
        orderDealService.update(orderDeal);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Integer id){
        orderDealService.delete(id);
        return new Result();
    }

    @GetMapping("/orderDealfindByTime")
    public List<Map> orderDealfindByTime(String date1,String date2){
        return orderDealService.orderDealfindByTime(date1,date2);
    }

}
